package com.jiyun.behavior.service.ipl;


import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

import com.jiyun.behavior.mapper.ApBehaviorEntryMapper;
import com.jiyun.behavior.service.ApBehaviorEntryService;
import com.usian.model.behavior.ApBehaviorEntry;
import org.springframework.stereotype.Service;


import javax.annotation.Resource;

@Service
public class ApBehaviorEntryServiceipl extends ServiceImpl<ApBehaviorEntryMapper, ApBehaviorEntry>implements ApBehaviorEntryService {

//
//    @Override
//    public ResponseResult dianzan(LikesBehaviorDto dto) {
//        if (dto==null){
//            return ResponseResult.errorResult(AppHttpCodeEnum.PARAM_INVALID);
//        }
//
//
//        return null;
//    }
    @Resource
    ApBehaviorEntryMapper apBehaviorEntryMapper;

        public ApBehaviorEntry findbyUserIdOrEquipmentID(Integer userId,Integer equipmentId) {
            ApBehaviorEntry apBehaviorEntry=null;
            if (userId!=null){
                apBehaviorEntry = apBehaviorEntryMapper.selectOne(Wrappers.<ApBehaviorEntry>lambdaQuery().eq(ApBehaviorEntry::getEntryId, userId).eq(ApBehaviorEntry::getType,1));
                return apBehaviorEntry;
            }
            if (userId==null && equipmentId==null){
                 apBehaviorEntry = apBehaviorEntryMapper.selectOne(Wrappers.<ApBehaviorEntry>lambdaQuery().eq(ApBehaviorEntry::getType, 0));
                return apBehaviorEntry;
            }
            return apBehaviorEntry;
        }


}
